package bag;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-01-17
 * Time:17:00
 */
public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();

        binaryTree.preorder(binaryTree.creat());
        System.out.println();
        binaryTree.inorder(binaryTree.creat());
        System.out.println();
        binaryTree.postorder(binaryTree.creat());
        System.out.println();
        System.out.println(binaryTree.size(binaryTree.creat()));//遍历方法
        System.out.println(binaryTree.size1(binaryTree.creat()));//子问题方法
        System.out.println(binaryTree.getLeafNodeCount(binaryTree.creat()));
        System.out.println(binaryTree.getHeight(binaryTree.creat()));
        System.out.println(binaryTree.find(binaryTree.creat(), 'E'));
        //System.out.println(binaryTree.isCompleteTree(binaryTree.creat()));
        //binaryTree.level(binaryTree.creat());
    }

}

/*
根据先序结果创建二叉树
import java.util.*;
class TreeNode{
    public char val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(char val){
        this.val = val;
    }
}
public class Main{
    public static int i = 0;
    public static TreeNode creat(String str){//创建节点
        TreeNode root = null;
        if(str.charAt(i) != '#'){//不是空格就创建，
            root = new TreeNode(str.charAt(i));
            i ++;
            root.left = creat(str);
            root.right = creat(str);
        }else{//'#'就是空树
            i ++;
        }
        return root;
    }
    public static void inorder(TreeNode root){//中序遍历
        if(root == null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val + " ");
        inorder(root.right);
    }
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        while(input.hasNextLine()){//多次输入
            String s = input.nextLine();
            TreeNode root = creat(s);
            inorder(root);
        }
    }
}
 */